package com.colin.userservice.config;

import cn.hutool.core.lang.Snowflake;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class IdConfig {

    @Value("${snowflake.worker-id}")
    private Integer workId;

    @Value("${snowflake.datacenter-id}")
    private Integer dataCenterId;

    @Bean
    public Snowflake snowflake() {

        return new Snowflake(workId, dataCenterId);
    }
}
